ExternalProject_Add(llvm-libcxx
    DEPENDS
        mingw-w64-headers
    DOWNLOAD_COMMAND ""
    UPDATE_COMMAND ""
    SOURCE_DIR ${LLVM_SRC}
    LIST_SEPARATOR ^^
    CONFIGURE_COMMAND ${EXEC} _IS_CONFIGURE=1 ${CMAKE_COMMAND} -H<SOURCE_DIR>/runtimes -B<BINARY_DIR>
        ${cmake_conf_args}
        -DCMAKE_DISABLE_FIND_PACKAGE_LLVM=ON
        -DCMAKE_DISABLE_FIND_PACKAGE_Clang=ON
        -DLLVM_ENABLE_RUNTIMES='libunwind^^libcxxabi^^libcxx'
        -DLIBUNWIND_USE_COMPILER_RT=ON
        -DLIBUNWIND_ENABLE_SHARED=OFF
        -DLIBUNWIND_ENABLE_STATIC=ON
        -DLIBCXX_ABI_UNSTABLE=ON
        -DLIBCXX_USE_COMPILER_RT=ON
        -DLIBCXX_ENABLE_SHARED=OFF
        -DLIBCXX_ENABLE_STATIC=ON
        -DLIBCXX_HARDENING_MODE=fast
        -DLIBCXX_INSTALL_MODULES=OFF
        -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
        -DLIBCXX_CXX_ABI=libcxxabi
        -DLIBCXX_INCLUDE_TESTS=OFF
        -DLIBCXXABI_INCLUDE_TESTS=OFF
        -DLIBUNWIND_INCLUDE_TESTS=OFF
        -DLIBCXX_INCLUDE_DOCS=OFF
        -DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=OFF
        -DLIBCXX_HAS_WIN32_THREAD_API=ON
        -DLIBCXXABI_HAS_WIN32_THREAD_API=ON
        -DLIBCXXABI_USE_COMPILER_RT=ON
        -DLIBCXXABI_USE_LLVM_UNWINDER=ON
        -DLIBCXXABI_ENABLE_SHARED=OFF
        -DLIBUNWIND_INCLUDE_DOCS=OFF
        -DLIBCXXABI_ENABLE_ASSERTIONS=OFF
        -DLIBUNWIND_ENABLE_ASSERTIONS=OFF
        -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
    BUILD_ENVIRONMENT_MODIFICATION
        _PACKAGE_NAME=set:${package}
        _BINARY_DIR=set:<BINARY_DIR>
        _IS_EXCEPTIONS_ALLOWED=set:1
        _FULL_DEBUGINFO=set:1
        _NOCCACHE=set:1
    BUILD_COMMAND ${EXEC} ninja -C <BINARY_DIR>
    INSTALL_COMMAND ${EXEC} ${CMAKE_COMMAND} --install <BINARY_DIR>
            COMMAND ${EXEC} ${CMAKE_COMMAND} -E copy ${MINGW_INSTALL_PREFIX}/lib/libc++.a ${MINGW_INSTALL_PREFIX}/lib/libstdc++.a
    LOG_DOWNLOAD 1 LOG_UPDATE 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
)

cleanup(llvm-libcxx install)
